package com.material.c2c.web.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 获取当前请求的request工具
 *
 * @author raozhidan（rao.zhidan@sccaptain.com.cn）
 * @create 2018/2/8
 */
public class CurrentRequestUtil {
  private static ThreadLocal<HttpServletRequest> threadLocal = new ThreadLocal();
  private static ThreadLocal<HttpServletResponse> responseThreadLocal = new ThreadLocal();

  public static HttpServletRequest getHttpServletRequest() {
    return threadLocal.get();
  }

  public static void setHttpServletRequest(HttpServletRequest request) {
    threadLocal.set(request);
  }

  public static void removeHttpServletRequest() {
    threadLocal.remove();
  }

  public static HttpServletResponse getHttpServletResponse() {
    return responseThreadLocal.get();
  }

  public static void setHttpServletResponse(HttpServletResponse response) {
    responseThreadLocal.set(response);
  }

  public static void removeHttpServletResponse() {
    responseThreadLocal.remove();
  }
}
